package efg.library.JAAS;

import java.io.Serializable;
import java.security.Principal;

public class MyPrincipal implements Principal, Serializable {
	private static final long serialVersionUID = 1L;
	protected String name = null;

	public MyPrincipal(String newName) {
		if (newName == null)
			throw new NullPointerException("illegal null input");
		name = newName;
	}

	public String getName() {
		return name;
	}

	public boolean equals(Object o) {
		boolean ret = false;
		if (o != null)  {
			if (o instanceof MyPrincipal) {
				MyPrincipal other = (MyPrincipal)o;
				if (this.name.equals(other.name)) ret = true;
			}
		}
		return ret;
	}

	public int hashCode() {
		return name.hashCode();
	}

	public String toString() {
		return name;
	}
}